<template>
  <div class="integrate">
    <PubTitle title="积分排行榜" />
    <ul>
      <li v-for="(v, i) in tableData" :key="i">
        <img :src="headPic(v)" alt="" />
        <div class="rank-info">
          <p class="username">{{ v.userInfo.userName }}</p>
          <p class="">{{ v.userInfo.deptName }}</p>
          <p class="score">{{ v.score }}</p>
          <el-progress
            :text-inside="true"
            :stroke-width="10"
            :percentage="percentage(i)"
          ></el-progress>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { sysUserScoreQueryUserScoreList } from "@/api/admin/system/sysScoreRule";
export default {
  components: {
    PubTitle: () => import("./pubTitle.vue"),
  },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 4,
      },
      tableData: [],
      pageObj: {},
    };
  },
  computed: {
    headPic() {
      return function (v) {
        if (v.userInfo.hasOwnProperty("sysAttachment")) {
          return v.userInfo.sysAttachment.httpUrl;
        } else {
          return this.$store.getters.headPic;
        }
      };
    },
    percentage() {
      return function (idx) {
        return 90 - 10 * idx;
      };
    },
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      sysUserScoreQueryUserScoreList(this.listQuery).then((res) => {
        this.tableData = res.data.data;
        this.pageObj = res.data;
      });
    },
  },
};
</script>
<style scoped lang="scss">
.integrate {
  ul {
    padding-top: 10px;
    li {
      position: relative;
      height: 68px;
      padding: 15px 0;
      img {
        position: absolute;
        left: 0px;
        top: 15px;
        width: 60px;
        height: 60px;
        border: 3px solid rgba(139, 198, 255, 0.6);
        border-radius: 50%;
      }
      .rank-info {
        padding-left: 80px;
      }
      p {
        float: left;
        font-size: 16px;
        line-height: 40px;
      }
      .username {
        font-weight: bold;
        color: #fff;
        margin-right: 10px;
      }
      .score {
        float: right;
        font-size: 13px;
        font-weight: bold;
        color: #0b5bc8;
      }
    }
  }
}
</style>
<style scoped>
.integrate >>> .el-progress-bar__innerText {
  display: none;
}
.integrate >>> .el-progress-bar__inner {
  background-image: linear-gradient(to right, #50a9fb, #e198f4);
}
</style>